/*************************************************************************
	> File Name: test1.cc
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/09/19 13:39
 ************************************************************************/

#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>

int main(int argc, char *argv[])
{
    pid_t id = fork();
    if (id == 0) {
        sleep(1);
        int a = 100;
        a /= 0;
        exit(0);
    }
    int status = 0;
    waitpid(id, &status, 0);
    std::cout << "Father process:" << getpid() << ", Child process:" << id << ", exit sig:" << (status & 0x7f) << ", is core:" << ((status >> 7) & 1) << std::endl;
    return 0;
}
